package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseData;
import com.cskaoyan.bean.BaseParam;
import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.User;
import com.cskaoyan.service.UserService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("admin/user")
public class UserController {

    @Autowired
    UserService userService;

    // filterChainDefinitionMap.put("/admin/user/list","perm[study]")
    //logical权限之间的关系是and还是or
    @RequiresPermissions(value = {"study","eat","sleep"},logical = Logical.AND)
    @RequestMapping("list")
    public BaseRespVo list(BaseParam param, String username, String mobile) {
        BaseData<User> data = userService.query(param, username, mobile);
        return BaseRespVo.ok(data);
    }

}
